#ifndef UPDATER_H
#define UPDATER_H

#include <QDialog>
#include <QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QFile>
#include <QProcess>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
#include <QCloseEvent>
#include <QWidget>
#include <windows.h>

#include "dbmanager.h"
#include "config.h"

namespace Ui {
class Updater;
}

class Updater : public QDialog
{
    Q_OBJECT

signals:
    void updateFinished();

public:
    explicit Updater(QWidget *parent = nullptr);
    ~Updater();
    void downloadAndUpdate();
    void checkUpdate();

private:
    QVector<int> parseVersion(const QString &version);
    bool isVersionHigher(const QString &remoteVersion, const QString &localVersion);

private:
    Ui::Updater *ui;
    DBManager m_db;
    QNetworkAccessManager *m_manager;
    QNetworkReply *m_reply;
};

#endif // UPDATER_H
